﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;

namespace TuyennvLibrary.Notify
{
    public class NotifyResponse
    {
        public int Success { get; set; }
        public int Failure { get; set; }
        public NotifyResponse()
        {
            this.Success = 0;
            this.Failure = 0;
        }
        public NotifyResponse(Object response)
        {
            JObject item = JObject.FromObject(response);
            this.Success += (int)item["success"];
            this.Failure += (int)item["failure"];
        }
        public NotifyResponse(List<object> listResponse)
        {
            JArray jarray = JArray.FromObject(listResponse);
            foreach (JObject item in jarray)
            {
                this.Success += (int)item["success"];
                this.Failure += (int)item["failure"];
            }

        }
        public void AddSuccess()
        {
            AddSuccess(1);
        }
        public void AddSuccess(int num)
        {
            this.Success += num;
        }
        public void AddFailure()
        {
            AddFailure(1);
        }
        public void AddFailure(int num)
        {
            this.Failure += num;
        }
        public void Add(NotifyResponse response)
        {
            AddSuccess(response.Success);
            AddFailure(response.Failure);
        }
        public override string ToString()
        {
            return string.Format("Success: {0}\nFailure:{1}", Success, Failure);
        }
    }
}
